<template>
    <!-- 食堂信息维护 -->
    <base-breadcrumb :title="$route.meta.title">
        <!-- 搜索 -->
        <searchData :searchData="searchArr" @search="search"></searchData>
        <!-- 表格 -->
        <a-card :bordered="false">
            <!-- <title-name :title="$route.meta.title"></title-name> -->
            
            <!-- 表格 -->
            <list-table
                ref="table"
                row-key="id"
                :columns="columns"
                :request="loadData"
                :alert="true"
                show-size-changer
                show-quick-jumper
            >
            <a-button slot="prefix" slot-scope="ref" class="mb12" icon="plus" type="primary" @click="handleManage(2)">新增</a-button>
            <span slot="index" slot-scope="text, record, index">{{ index + 1 }}</span>
                <template slot="action" slot-scope="text, record">
                    <a @click="handleManage(0, record)">查看</a>
                    <a-divider type="vertical"></a-divider>
                    <a @click="handleManage(1, record)">编辑</a>
                    <!-- 删除 -->
                    <!-- <a-divider type="vertical"></a-divider>
                    <a class="del_btn" @click="handleRemoves([record.id])">删除</a> -->
                </template>
            </list-table>
        </a-card>
    </base-breadcrumb>
</template>

<script>
// import { STable } from '@/components' // 表格
import { getPageOfficeCanteen } from '@/api/office/canteen' // api
import BasePage from '@/views/basePage' // 基础配置
import SelectCompanyAndProject from '@/components/Select/SelectCompanyAndProject'
import OrgTreeSelect from '@/components/OrgTreeSelect/index'
const searchArr = [
    // 搜索框
    {
        name: '单位',
        valueKey: 'searchQuery',
        type: OrgTreeSelect,
    },
    {
        name: '经营者名称',
        value: 'maintainerName',
        type: 'input',
    },
    {
        name: '状态',
        value: 'status',
        type: 'select',
        data: [
            {
                value: '0',
                label: '不可用',
            },
            {
                value: '1',
                label: '可用',
            },
        ],
    },
]
const columns = [
    {
        title: '序号',
        width: 80,
        dataIndex: 'index',
        scopedSlots: { customRender: 'index' }
    },
    {
        title: '所属单位',
        dataIndex: 'orgIdStr',
    },
    {
        title: '食堂名称',
        ellipsis: true,
        dataIndex: 'canteenName',
    },
    {
        title: '规模(m²)',
        ellipsis: true,
        dataIndex: 'scale',
    },
    {
        title: '最多可容纳人数',
        ellipsis: true,
        dataIndex: 'maxNumPeople',
    },
    {
        title: '包间数量',
        ellipsis: true,
        dataIndex: 'roomsNum',
    },
    {
        title: '工作人员人数',
        dataIndex: 'staffNum',
        ellipsis: true,
    },
    {
        title: '经营者名称',
        dataIndex: 'maintainerName',
        ellipsis: true,
    },
    // {
    //     title: '满意度平均得分',
    //     dataIndex: 'satisfactionScore',
    //     ellipsis: true,
    // },
    // {
    //     title: '日常考核平均得分',
    //     dataIndex: 'assessmentScore',
    //     ellipsis: true,
    // },
    {
        title: '状态',
        dataIndex: 'statusStr',
        ellipsis: true,
    },
    {
        title: '操作',
        dataIndex: 'action',
        width: '180px',
        align: 'center',
        scopedSlots: { customRender: 'action' },
    },
]
export default {
  name:'a'+Date.now(),
  extends: new BasePage(),
    components: {
        // STable,
    },
    data() {
        this.columns = columns
        this.searchArr = searchArr
        return {
            queryParam: {}, // 查询参数
            loadData: (parameter) => {
                const requestParameters = Object.assign({}, parameter, { query: this.queryParam })
                return getPageOfficeCanteen(requestParameters).then((res) => {
                    return res
                })
            }, // 加载数据方法 必须为 Promise 对象

            editModel: 0,
            form: {},
            position: '',
        }
    },
    mounted() {
        this.position = this.$currentPost()?.postCode
    },
    methods: {
        // 搜索
        search(value) {
            value && (this.queryParam = value)
            this.$refs.table.refresh(true)
        },
        // 操作栏
        handleManage(type, record) {
            this.editModel = type
            let query = {
                editModel: type,
            }
            if (record && record.id) {
                query.id = record.id
            }
            this.$router.push({
                name: '/office/canteen/InformationMaintenance/updateInformationMaintenance',
                query,
            })
        },
    },
}
</script>
